<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="widtd=device-widtd, initial-scale=1.0">
    <title>添加页</title>
    <link rel="stylesheet" href="./static/css/index.css">
</head>

<body>

    <div>
        <div>
            <h1>添加页</h1>
        </div>
        <div>
            <table>
                <tr>
                    <td>
                        姓名: <input type="text" placeholder="请输入姓名" id="uname">
                    </td>
                    <td>
                        年龄: <input type="text" placeholder="请输入年龄" id="uage">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="确认" onclick="saveU()">
                        <input type="button" value="返回" onclick="cancelU()">
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <script src="./static/js/axios.min.js"></script>
    <script>


        function saveU() {
            if (confirm("确认添加吗???")) {
                let uname = document.querySelector('#uname').value
                let uage = document.querySelector('#uage').value
                axios.post("http://localhost:3000/user", { uname, uage }).then(() => {
                    location.href = './index.html'
                })
            }
        }

        function cancelU() {
            location.href = './index.html'
        }
    </script>
</body>

</html>